﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

namespace SportingGoodsExhibitionSystem
{
    /// <summary>
    /// AdminStuHeaTable.xaml 的交互逻辑
    /// </summary>
    public partial class AdminStuHeaTable : Window
    {
        string strCon = Properties.Resources.strCON;

        public AdminStuHeaTable()
        {
            InitializeComponent();
        }
        int stuNum;
        public AdminStuHeaTable(int stuNum)
        {
            InitializeComponent();
            this.stuNum = stuNum;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            SqlConnection con = new SqlConnection(strCon);
            con.Open();
            SqlCommand cmd = new SqlCommand("select * from heathyTable where stunum=@num", con);
            cmd.Parameters.Add("@num", SqlDbType.Int, 10).Value = stuNum;
            SqlDataAdapter read = new SqlDataAdapter(cmd);
            //DataTable dt = new DataTable();
            DataSet dataset = new DataSet();
            read.Fill(dataset);
            DataTable table = dataset.Tables[0];
            DataRowCollection rows = table.Rows;
            DataRow row = rows[0];
            int first = Convert.ToInt32(row["first"].ToString());
            int second = Convert.ToInt32(row["second"].ToString());
            int third = Convert.ToInt32(row["third"].ToString());
            int fourth = Convert.ToInt32(row["forth"].ToString());
            int fifth = Convert.ToInt32(row["fifth"].ToString());
            int sixth = Convert.ToInt32(row["sixth"].ToString());
            if(first==0)
            {
                labelFirst.Content = "否";
            }
            else
            {
                labelFirst.Content = "是";
            }
            if (second == 0)
            {
                labelSecond.Content = "否";
            }
            else
            {
                labelSecond.Content = "是";
            }
            if (third == 0)
            {
                labelThird.Content = "否";
            }
            else
            {
                labelThird.Content = "是";
            }
            if (fourth == 0)
            {
                labelFourth.Content = "否";
            }
            else
            {
                labelFourth.Content = "是";
            }
            if (fifth == 0)
            {
                labelFifth.Content = "否";
            }
            else
            {
                labelFifth.Content = "是";
            }
            if (sixth == 0)
            {
                labelSixth.Content = "否";
            }
            else
            {
                labelSixth.Content = "是";
            }

            con.Close();
        }
    }
}
